<style lang="less" scoped>
    .storage {
        width: 100%;
        height: auto;
        overflow: hidden;
        text-align: center;
        padding: 8px;
        display: flex;
    }
</style>
<template>
    <div class="storage">
        <card-table
            cardtitle="出入库记录"
            addbuttext="新增出入库"
            :columns="columns"
            :selectList="selectList"
            :defaultSelete="defaultSelete"
            :searchForm="searchForm"
            :formItem="formItem"
            :addbtn = false
            @add="add"
            @refresh="refresh"
            @on-current-change="onCurrentChange"
            :data="data">
        </card-table>
    </div>
</template>
<script>
    import CardTable from '../components/cardTable.vue'
    import MyCard from '../components/myCard.vue'
    import storagedata from './storagedata.js'
    export default {
        name: 'storage',
        data () {
            return {
                columns: [
                    {
                        title: '操作时间',
                        key: 'time'
                    },
                    {
                        title: '操作人',
                        key: 'user'
                    },
                    {
                        title: '物料编号',
                        key: 'nub'
                    },
                    {
                        title: '物料类型',
                        key: 'type'
                    },
                    {
                        title: '操作类型',
                        key: 'dotype'
                    },
                    {
                        title: '数量',
                        key: 'number',
                        render: (h, params) => {
                            return h('span', params.row.number + params.row.unit)
                        }
                    }
                ],  //  表格列
                data: storagedata,  //  表格数据
                selectList: [
                    {
                        label: '编号',
                        value: 'nub'
                    },
                    {
                        label: '名称',
                        value: 'name'
                    },
                    {
                        label: '单位',
                        value: 'unit'
                    },
                    {
                        label: '类型',
                        value: 'type'
                    },
                    {
                        label: '备注',
                        value: 'remark'
                    }
                ],  //  搜索下拉列表
                defaultSelete: 'nub',  //  搜索下拉列表默认值
                searchForm: {
                    'nub': '',
                    'name': '',
                    'unit': '',
                    'type': '',
                    'remark': ''
                },  //  表单初始值
                formItem: [
                    {
                        label: '编号',
                        key: 'nub',
                        placeholder: '请输入物料编号'
                    },
                    {
                        label: '名称',
                        key: 'name',
                        placeholder: '输入物料名称'
                    },
                    {
                        label: '单位',
                        key: 'unit',
                        placeholder: '输入物料单位'
                    },
                    {
                        label: '类型',
                        key: 'type',
                        placeholder: '输入物料类型'
                    }
                ],  //  搜索表单item
                current: null
            }
        },
        filters: {
            storagetype: function (value) {
                switch (value){
                    case '1':
                        return '出库'
                    case '2':
                        return '入库'
                    case '3':
                        return '进料'
                }
            },
            workorderstate: function (value) {
                switch (value){
                    case '1':
                        return '待生产'
                    case '2':
                        return '未生产'
                    case '3':
                        return '已生产'
                }
            }
        },
        methods: {
            add () {
                console.log('customer触发了添加事件')
            },
            refresh () {
                console.log('customer触发了刷新事件')
            },
            onCurrentChange (current) {
                console.log(current)
                this.current = current
            },
            storageall () {
                console.log('出入库全部信息')
            },
            storageclick () { //  出入库详情按钮
                console.log('出入库详情')
            },
            gdclick () { //  工单列表查看按钮
                console.log('工单列表查看')
            }
        },
        components: {
            CardTable,
            MyCard
        },
        mounted: function () {
            console.log('customer被初始化了')
        }
    };
</script>
